//
//  EmptyOrderTableCell.m
//  ATMCash
//
//  Created by zhengchengfeng on 2024/9/9.
//

#import "EmptyOrderTableCell.h"

@implementation EmptyOrderTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        UIImage *img = [UIImage imageNamed:@"icon_empty"];
        
        self.iconV = [[UIImageView alloc] init];
        [self.contentView addSubview:self.iconV];
        [self.iconV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@((kScreenWidth - img.size.width)/2));
            make.width.equalTo(@(img.size.width));
            make.height.equalTo(@(img.size.height));
            make.top.equalTo(self.contentView.mas_top).offset(40);
        }];
        
        UIImage *btnImg = [UIImage imageNamed:@"icon_emptyBtn"];
        self.btn = [[UIButton alloc] init];
        self.btn.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:13];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateSelected];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateHighlighted];
        [self.contentView addSubview:self.btn];
        [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@((kScreenWidth - btnImg.size.width)/2));
            make.width.equalTo(@(btnImg.size.width));
            make.height.equalTo(@(btnImg.size.height));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-20);
        }];
        [self.btn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
        
        self.titleLab = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(205, 220, 207)];
        self.titleLab.numberOfLines = 2;
        self.titleLab.textAlignment = 1;
        [self.contentView addSubview:self.titleLab];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(40);
            make.right.equalTo(self.contentView.mas_right).offset(-40);
            make.top.equalTo(self.iconV.mas_bottom).offset(5);
            make.bottom.equalTo(self.btn.mas_top).offset(-5);
        }];
        
        
    }
    return self;
}

- (void)clickBtn{
    if (_clickBtnBlock) {
        _clickBtnBlock();
    } 
}

- (void)setIsNoData:(BOOL)isNoData{
    _isNoData = isNoData;
    
    if (isNoData) {
        self.iconV.image = [UIImage imageNamed:@"icon_empty"];
        self.titleLab.text = @"There is no order record yet";
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateNormal];
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateSelected];
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateHighlighted];
        [self.btn setTitle:@"Go Apply" forState:UIControlStateNormal];
        [self.btn setTitle:@"Go Apply" forState:UIControlStateSelected];
        [self.btn setTitle:@"Go Apply" forState:UIControlStateHighlighted];
    } else {
        self.iconV.image = [UIImage imageNamed:@"icon_empty2"];
        self.titleLab.text = @"Network error,please try again later or contact our customer service";
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateNormal];
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateSelected];
        [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateHighlighted];
        [self.btn setTitle:@"Try Again" forState:UIControlStateNormal];
        [self.btn setTitle:@"Try Again" forState:UIControlStateSelected];
        [self.btn setTitle:@"Try Again" forState:UIControlStateHighlighted];
    }
    
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


@implementation EmptyHomeTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        UIImage *img = [UIImage imageNamed:@"icon_empty"];
        
        self.iconV = [[UIImageView alloc] init];
        [self.contentView addSubview:self.iconV];
        [self.iconV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@((kScreenWidth - img.size.width)/2));
            make.width.equalTo(@(img.size.width));
            make.height.equalTo(@(img.size.height));
            make.top.equalTo(self.contentView.mas_top).offset((kScreenHeight/2 - 180));
        }];
        
        
        
        self.titleLab = [Utility createLabel:[UIFont fontWithName:kFuturaMedium size:13] color:RGB(205, 220, 207)];
        self.titleLab.numberOfLines = 2;
        self.titleLab.textAlignment = 1;
        [self.contentView addSubview:self.titleLab];
        [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(40);
            make.right.equalTo(self.contentView.mas_right).offset(-40);
            make.top.equalTo(self.iconV.mas_bottom).offset(5);
            make.height.equalTo(@50);
        }];
        
        UIImage *btnImg = [UIImage imageNamed:@"icon_emptyBtn"];
        self.btn = [[UIButton alloc] init];
        self.btn.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:13];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateSelected];
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateHighlighted];
        [self.contentView addSubview:self.btn];
        [self.btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@((kScreenWidth - btnImg.size.width)/2));
            make.width.equalTo(@(btnImg.size.width));
            make.height.equalTo(@(btnImg.size.height));
            make.top.equalTo(self.titleLab.mas_bottom).offset(5);
        }];
        [self.btn addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

- (void)clickBtn{
    if (_clickBtnBlock) {
        _clickBtnBlock();
    }
}

- (void)setIsErrorData:(BOOL)isErrorData{
    _isErrorData = isErrorData;
    
    self.iconV.image = [UIImage imageNamed:@"icon_empty2"];
    self.titleLab.text = @"Network error,please try again later or contact our customer service";
    [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateNormal];
    [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateSelected];
    [self.btn setBackgroundImage:[UIImage imageNamed:@"icon_emptyBtn"] forState:UIControlStateHighlighted];
    [self.btn setTitle:@"Try Again" forState:UIControlStateNormal];
    [self.btn setTitle:@"Try Again" forState:UIControlStateSelected];
    [self.btn setTitle:@"Try Again" forState:UIControlStateHighlighted];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
